# 作业1 读取分类信息
import  lxml.etree  as le
with open('zuoye1.html','r',encoding='utf-8') as f :
    html = f.read()
    htmlx = le.HTML(html)
    category_list_s = htmlx.xpath('//div[@class="classify_cList"]')
    # print(category_list_s)
    data = []
    for category_list in category_list_s:
        data .append( {
            'category_name' : category_list.xpath('./h3[@class="classify_c_h3"]/a/text()')[0],
            "category_content" : category_list.xpath('./div[@class="classify_list"]/span/a/text()')
        })
    for d in data:
        print(d.get('category_name'))
        for x in d.get("category_content"):
            print(' '*6,x)
